define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) {

    var Controller = {
        index: function () {
            // 基于准备好的dom，初始化echarts实例
            this.chart.myChart = Echarts.init(document.getElementById('echart'), 'walden');
            let that = this;
            $(document).on("click", ".btn-my-chart", function () {
               that.chart.order($(this).data('id'));
            });
            this.chart.order(0);
        },
        chart: {
            myChart:null,
            order: function (id) {
                let that = this;
                Fast.api.ajax({
                    url: 'mental/report/order',
                    data: { id: id }
                }, function (data, ret) {
                    //成功的回调
                    that.myChart.setOption(ret.data)
                    return false;
                }, function (data, ret) {
                    //失败的回调
                    console.log('error', ret);
                    return false;
                });
            }
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});